package com.gao.security.verificationcode.common.vo;

import com.gao.security.verificationcode.common.enums.ResponseCode;
import lombok.Data;

import java.io.Serializable;

/**
 * <p></p>
 *
 * @author GaoShuangWen
 */
@Data
public class ExceptionVo implements Serializable {
    /**
     * 状态码
     */
    private Integer code;
    /**
     * 返回体
     */
    private Object data;
    /**
     * 描述信息
     */
    private String msg;

    public static ExceptionVo exception(Exception e) {
        ExceptionVo exceptionVo = new ExceptionVo();
        exceptionVo.setResponseCode(ResponseCode.PERMISSION_NO_ACCESS);
        exceptionVo.setData(e.getMessage());
       /* if(e instanceof OAuth2Exception){
        }*/
        return exceptionVo;
    }

    public void setResponseCode(ResponseCode code) {
        this.code = code.code();
        this.msg = code.message();
    }
}
